<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>论坛列表</title>
    <meta name="context-path" th:content="@{/}"/>
    <link rel="stylesheet" th:href="@{/resources/matrix/css/bootstrap.min.css}"/>
    <link rel="stylesheet" th:href="@{/resources/matrix/css/bootstrap-responsive.min.css}"/>
    <link rel="stylesheet" th:href="@{/resources/matrix/css/matrix-style.css}"/>
    <link rel="stylesheet" th:href="@{/resources/matrix/css/matrix-media.css}"/>
    <link rel="stylesheet" th:href="@{/resources/matrix/css/matrix-full.css}"/>
    <link rel="stylesheet" th:href="@{/resources/matrix/font-awesome/css/font-awesome.css}"/>
    <link rel="stylesheet" th:href="@{/resources/layui/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{/resources/css/website.css}"/>
    <style>
        .layui-table-click{
            background-color: #FF7F24;
        }
    </style>
</head>
<body class="childbody">
<div class="container-fluid">
    <!--Chart-box-->
    <div class="row-fluid">
        <div class="widget-box">
            <div class="widget-title bg_lg"><span class="icon"><i class="icon-search"></i></span>
                <h5>查询</h5>
            </div>
            <div class="widget-content nopadding">
                <form id="queryform" action="#" method="get" class="form-horizontal query-form">
                    <div class="row-fluid query-row">
                        <!--<div class="span3">
                            <div class="control-group">
                                <label class="control-label">类型：</label>
                                <div class="controls form-group">
                                    <select class="span11 form-control" name="status">
                                        <option value="">-&#45;&#45;请选择-&#45;&#45;</option>
                                        <option th:each="rl : ${typeEnums}" th:value="${rl.value}"
                                                th:text="${rl.name}"></option>
                                    </select>
                                </div>
                            </div>
                        </div>-->
                        <div class="span3">
                            <div class="control-group">
                                <label class="control-label query-control-label">标题：</label>
                                <div class="controls query-controls">
                                    <input type="text" name="keyword" class="span11" placeholder="请输入标题">
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="form-actions">
                        <button id="btnSearch" type="button" class="btn btn-primary">查询</button>
                    </div>
                </form>
            </div>
        </div>
        <!--End-Chart-box-->
        <div class="row-fluid">
            <div class="span12">
                <div class="widget-box">
                    <div class="widget-title"><span class="icon"> <i class="icon-th"></i> </span>
                        <h5>论坛帖列表</h5>
                    </div>
                    <div class="widget-content nopadding">
                        <div class="table_actions">
                            <!--<button id="btnAdd" class="btn  btn-primary">添加</button>
                            <button id="btnView" class="btn btn-success">查看</button>
                            <button id="btnEdit" class="btn btn-info">修改</button>-->
                            <button id="btnDelete" class="btn btn-danger">删除</button>
                            <button id="btnDoTop"  type="button"  class="btn btn-primary">设为精华帖</button>
                            <button id="btnCancelTop"  type="button"  class="btn btn-success">取消精华帖</button>
                            <!--<button id="btnRelease" class="btn btn-info">发布</button>
                            <button id="btnDisabled" type="button" class="btn btn-danger">结束测评</button>
                            <button id="btnExport" class="btn btn-primary">导出</button>
                            <button id="btnImport"  type="button"  class="btn btn-success">导入</button>-->
                        </div>
                        <table id="tablelist" class="layui-table" lay-filter="question_list">
                        </table>
                    </div>
                </div>
            </div>

        </div>
        <div class="row-fluid">
            <div class="span7">
                <div class="widget-box">
                    <div class="widget-title"><span class="icon"> <i class="icon-th"></i> </span>
                        <h5>帖子评论列表</h5>
                    </div>
                    <div class="widget-content nopadding">
                        <div class="table_actions">
                            <!--<button id="btnAddItem" class="btn  btn-primary">添加</button>
                            <button id="btnEditItem" class="btn btn-info">修改</button>-->
                            <button id="btnDeleteItem" class="btn btn-danger">删除</button>
                        </div>
                        <table id="itemlist" class="layui-table" lay-filter="item_list">
                        </table>
                    </div>
                </div>
            </div>
            <div class="span5">
                <div class="widget-box">
                    <div class="widget-title"><span class="icon"> <i class="icon-th"></i> </span>
                        <h5>评论回复列表</h5>
                    </div>
                    <div class="widget-content nopadding">
                        <div class="table_actions">
                            <!--<button id="btnAddOption" class="btn btn-primary">添加</button>
                            <button id="btnEditOption" class="btn btn-info">修改</button>-->
                            <button id="btnDeleteOption" class="btn btn-danger">删除</button>
                        </div>
                        <table id="optionlist" class="layui-table">
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script th:src="@{/resources/matrix/js/jquery.min.js}"></script>
<script th:src="@{/resources/matrix/js/jquery.ui.custom.js}"></script>
<script th:src="@{/resources/matrix/js/bootstrap.min.js}"></script>
<script th:src="@{/resources/matrix/js/matrix.js}"></script>
<script th:src="@{/resources/js/website.js}"></script>
<script th:src="@{/resources/layui/layui.all.js}" charset="utf-8"></script>
<script th:src="@{/resources/js/system.js}"></script>
<script th:inline="javascript">
    var contextRoot = $("meta[name='context-path']").attr("content");

    $(document).keyup(function (event) {
        if (event.keyCode == 13) {
            search();
        }
    });
</script>

<script th:inline="javascript">
    /*<![CDATA[*/
    var query, add, edit,view,importExcel, del,release, queryItem, addItem,editItem,exports, queryOption,addOption,editOption,deleteItem,deleteOption,postId,commentId,commentId,disabled ,doTop ,cancelTop;
    layui.use(['jquery', 'layer', 'table', 'laydate'], function () {
        var $ = layui.jquery,
            layer = layui.layer,
            table = layui.table;

        lay('.date').each(function () {
            laydate.render({
                elem: this
            });
        });

        var cols = [
            [
                {type: 'checkbox'},
                {field: 'title', width: '15%',event: 'getItem', title: '标题', sort: true},
                {field: 'content', width: '35%',event: 'getItem',title: '内容', sort: true},
                {field: 'authorName', width: '10%',event: 'getItem',title: '作者', sort: true},
                {field: 'isTop', width: '8%',event: 'getItem', title: '是否精华', sort: true},
                {field: 'type', width: '8%',event: 'getItem', title: '类型', sort: true},
                {field: 'readCount', width: '10%',event: 'getItem', title: '阅读量', sort: true},
                {field: 'createTime',event: 'getItem', width: '10%', title: '创建时间', sort: true}
            ]
        ];

        query = new ListQuery(table, {
            cols: cols,
            element: "#tablelist",
            url: contextRoot + "forumPost/postList",
            page: 1,
            even:false,
            filter: "question_list",
            tableid: "point_question_list_table",
            extraData: function () {
                return $("#queryform").serializeObject();
            },
            onRowChecked: function (row) {
                postId = row.data.id;
                queryItem.reload();
            },
            onReload: function () {
                commentId = null;
            }
        })
        ;

        query.reload();

        release = new ListRelease(layer, query, {
            url: contextRoot + "forumPost/doRelease",
            msg: "确认发布选中的记录吗？"
        });

        disabled = new ListRelease(layer, query, {
            url: contextRoot + "forumPost/doDisabled",
            msg: "确认结束测评选中的记录吗？"
        });

        doTop = new ListRelease(layer, query, {
            url: contextRoot + "forumPost/doTop",
            msg: "确认该帖为精华帖？"
        });

        cancelTop = new ListRelease(layer, query, {
            url: contextRoot + "forumPost/cancelTop",
            msg: "确认取消该帖为精华帖？"
        });

        add = new ListAdd(layer, {
            title: "添加问卷",
            url: contextRoot + "forumPost/getAddQuestion",
            width: "860px",
            height: "750px"
        }, query);

        importExcel = new ListAdd(layer, {
            title: "导入问卷",
            url: contextRoot + "forumPost/goFileUpload",
            width: "860px",
            height: "350px"
        }, query);

        edit = new ListEdit(layer, {
            title: "修改问卷",
            url: contextRoot + "forumPost/getUpdateQuestion",
            width: "860px",
            height: "750px"
        }, query);

        view = new ListEdit(layer, {
            title: "查看问卷",
            url: contextRoot + "forumPost/getViewQuestion",
            width: "860px",
            height: "750px"
        }, query);

        del = new ListDelete(layer, query, {
            url: contextRoot + "forumPost/doDelete"
        });

        exports = new ListExport2(layer, query,{
            url: contextRoot + "forumPost/getExportQuestion"
        });

        $("#btnRelease").bind("click", function (event) {
            release.submit();
        });

        $("#btnAdd").bind("click", function (event) {
            add.openDialog();
        });

        $("#btnImport").bind("click", function (event) {
            importExcel.openDialog();
        });

        $("#btnSearch").bind("click", function (event) {
            query.reload();
        });

        $("#btnEdit").bind("click", function (event) {
            edit.openDialog();
        });

        $("#btnView").bind("click", function (event) {
            view.openDialog();
        });

        $("#btnDelete").bind("click", function (event) {
            del.submit();
        });

        $("#btnDisabled").bind("click", function (event) {
            disabled.submit();
        });

        $("#btnDoTop").bind("click", function (event) {
            doTop.submit();
        });

        $("#btnCancelTop").bind("click", function (event) {
            cancelTop.submit();
        });

        $("#btnExport").bind("click", function (event) {
            exports.submit();
        });

        //item
        var colItems = [
            [
                {type: 'checkbox'},
                {field: 'content', width: '45%',event: 'getOption', title: '内容', sort: true},
                {field: 'type', width: '10%', title: '类型',event: 'getOption', sort: true},
                {field: 'authorName', width: '15%', title: '作者姓名',event: 'getOption', sort: true},
                {field: 'createTime', width: '20%',event: 'getOption', title: '评论时间', sort: true}
            ]
        ];
        queryItem = new ListQuery(table, {
            cols: colItems,
            element: "#itemlist",
            url: contextRoot + "forumPost/commentList",
            page: 1,
            even:false,
            filter: "item_list",
            single: true,
            pageable: false,
            tableid: "question_item_list_table",
            extraData: function () {
                return {postId: postId};
            },
            onRowChecked: function (row) {
                commentId = row.data.id;
                queryOption.reload();
            },
            onReload: function () {
                commentId = null;
            }

        });

        addItem = new ListAdd(layer, {
            title: "添加问卷问题",
            url: contextRoot + "forumPost/getAddQuestionItem",
            width: "830px",
            height: "520px",
            getUrl: function (url) {
                return url + "/" + commentId;
            }
        }, queryItem);

        editItem = new ListEdit(layer, {
            title: "修改问卷问题",
            url: contextRoot + "forumPost/getUpdateItem",
            width: "830px",
            height: "520px",
            getUrl: function (url) {
                return url + "/" + commentId;
            }
        }, queryItem);

        deleteItem = new ListDelete(layer, queryItem, {
            url: contextRoot + "forumPost/doDeleteItem"
        });

        $("#btnAddItem").bind("click", function (event) {
            if (commentId) {
                addItem.openDialog();
            }
        });

        $("#btnEditItem").bind("click", function (event) {
            if (commentId) {
                editItem.openDialog();
            }
        });

        $("#btnDeleteItem").bind("click", function (event) {
            deleteItem.submit();
        });


        //option
        var colOptions = [
            [
                {type: 'checkbox'},
                {field: 'content', width: '40%', title: '内容', sort: true},
                {field: 'type', width: '15%', title: '类型', sort: true},
                {field: 'authorName', width: '15%', title: '作者姓名', sort: true},
                {field: 'createTime', width: '20%', title: '回复时间', sort: true}
            ]
        ];
        queryOption = new ListQuery(table, {
            cols: colOptions,
            element: "#optionlist",
            url: contextRoot + "forumPost/commentReplyList",
            page: 1,
            even:false,
            single: true,
            pageable: false,
            tableid: "question_option_list_table",
            extraData: function () {
                return {commentId: commentId};
            }
        });

        addOption = new ListAdd(layer, {
            title: "添加问题选项",
            url: contextRoot + "forumPost/getAddQuestionOption",
            width: "830px",
            height: "520px",
            getUrl: function (url) {
                return url + "/" + commentId;
            }
        }, queryOption);

        editOption = new ListEdit(layer, {
            title: "修改问卷问题",
            url: contextRoot + "forumPost/getEditQuestionOption",
            width: "830px",
            height: "520px",
            getUrl: function (url) {
                return url + "/" + commentId;
            }
        }, queryOption);

        deleteOption = new ListDelete(layer, queryOption, {
            url: contextRoot + "forumPost/doDeleteOption"
        });

        $("#btnAddOption").bind("click", function (event) {
            if (commentId) {
                addOption.openDialog();
            }
        });

        $("#btnEditOption").bind("click", function (event) {
            if (commentId) {
                editOption.openDialog();
            }
        });

        $("#btnDeleteOption").bind("click", function (event) {
            deleteOption.submit();
        });
    });


    /*]]>*/
</script>
</body>
</html>